const mongoose = require('mongoose');
const winston = require('../utils/winstonLogger.js');
let merchantModel = mongoose.model('Merchant');

module.exports = {
    findMerchant : findMerchant,
    updateMerchantStatus: updateMerchantStatus
}

function findMerchant($n={}, callback){
    merchantModel.find($n, function(err,docs){
        if(err){
            winston.error(err);
            callback(err,null);
        }else{
            console.log(docs);
            callback(null, docs);
        }
    });
}
function updateMerchantStatus(merchant, callback){
    console.log(merchant.reason);
    merchantModel.updateOne(
        {_id: merchant._id}, 
        {$set: {status: merchant.status,reason: merchant.reason}}, 
        function(err,docs){
            if(err){
                winston.error(err);
                callback(err, null);
            }else{
                console.log(docs);
                callback(null, docs);
            }
        });
}



